package com.whoami.idmagic.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

import static com.whoami.idmagic.hbase.HFileWriterJob.TABLE_NAME;
import static com.whoami.idmagic.hbase.HFileWriterJob.doBulkLoad;

/**
 * @author tzp
 * @since 2019/8/26
 */
public class LoadHFile extends Configured implements Tool  {
    @Override
    public int run(String[] strings) throws Exception {
        Configuration conf = getConf();
        conf.set("hbase.zookeeper.quorum", "jourm01.safe.lycc.qihoo.net,jourm02.safe.lycc.qihoo.net,jourm03.safe.lycc.qihoo.net,jourm04.safe.lycc.qihoo.net,jourm05.safe.lycc.qihoo.net");
        conf.setInt("hbase.zookeeper.property.clientPort", 2181);
        conf.set("zookeeper.znode.parent", "/hbase2");

        Connection connection = ConnectionFactory.createConnection(conf);
        doBulkLoad(conf.get("hfiledir"), conf.get("tablename"), conf, connection);
        return 0;
    }

    public static void main(String[] args) throws Exception {
        System.exit(ToolRunner.run(new Configuration(), new LoadHFile(), args));
    }
}
